<?php
/* This program is free software. It comes without any warranty, to
 * the extent permitted by applicable law. You can redistribute it
 * and/or modify it under the terms of the Do What The Fuck You Want
 * To Public License, Version 2, as published by Sam Hocevar. See
 * http://sam.zoy.org/wtfpl/COPYING for more details. */

ini_set('display_errors', 1);
error_reporting(E_ALL);
date_default_timezone_set('Asia/Bangkok');
require(__DIR__ . '/lib/SplClassLoader.php');
$classLoader = new SplClassLoader('Efy', __DIR__ . '/lib');
$classLoader->register();
@session_start();
$efyApp = new \Efy\Application();
$efyApp->run();
// Socket
$classLoader = new SplClassLoader('WebSocket', __DIR__ . '/lib');
$classLoader->register();
$server = new \WebSocket\Server('192.168.1.76', 9000, false);

// server settings:
$server->setMaxClients(300);
$server->setCheckOrigin(true);
$server->setAllowedOrigin('localhost:81');
$server->setAllowedOrigin('localhost:8080');
$server->setAllowedOrigin('192.168.1.76:81');
$server->setAllowedOrigin('192.168.1.76:8080');
$server->setMaxConnectionsPerIp(100);
$server->setMaxRequestsPerMinute(2000);

// Hint: Status application should not be removed as it displays usefull server informations:
$server->registerApplication('status', \WebSocket\Application\StatusApplication::getInstance());

$server->registerApplication('demo', \WebSocket\Application\DemoApplication::getInstance());

$server->run();